<template>
  <div>
    <a-card>
      <a-form-model ref="strutForm" :rules="strutFormRules" :model="strutDevise">
        <a-row :gutter="24">
          <a-col :span="12">
            <a-form-model-item
              label="支撑集群接口表名"
              prop="clusterTableName"
              :label-col="{ span: 6 }"
              :wrapper-col="{ span: 14 }"
            >
              <a-input v-model="strutDevise.clusterTableName" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item
              label="rowKey设计规则"
              prop="rowkeyRule"
              :label-col="{ span: 6 }"
              :wrapper-col="{ span: 14 }"
            >
              <a-input v-model="strutDevise.rowkeyRule" />
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row :gutter="24">
          <a-col :span="12">
            <a-form-model-item
              label="接口表当前数据量"
              prop="dataVolume"
              :label-col="{ span: 6 }"
              :wrapper-col="{ span: 14 }"
            >
              <a-input-number v-model="strutDevise.dataVolume" :min="0" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item
              label="数据增长量(条/日)"
              prop="dataGrowth"
              :label-col="{ span: 6 }"
              :wrapper-col="{ span: 14 }"
            >
              <a-input-number v-model="strutDevise.dataGrowth" :min="0" />
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
      <a-table :columns="clusterColumn" :data-source="clusterData"> </a-table>
    </a-card>
  </div>
</template>

<script>
export default {
  name: 'strutDeviseTab',
  props: {
    strut: {
      type: Object
    }
  },
  data() {
    return {
      strutDevise: this.strut,
      clusterData: this.strut.clusterTableList,
      clusterColumn: [
        { title: '字段名', dataIndex: 'columnName' },
        { title: '字段类型长度', dataIndex: 'columnType' },
        { title: '字段中文含义', dataIndex: 'columnCnMeaning' }
      ],
      strutFormRules: {
        clusterTableName: [{ required: true, message: '支撑集群接口表名不能为空', trigger: 'blur' }],
        rowkeyRule: [{ required: true, message: 'rowKey设计规则不能为空', trigger: 'blur' }],
        dataVolume: [{ required: true, message: '接口表当前数据量不能为空', trigger: 'blur' }],
        dataGrowth: [{ required: true, message: '数据增长量不能为空', trigger: 'blur' }]
      }
    }
  },
  watch: {
    strut(newVal) {
      this.strutDevise = newVal
      this.clusterData = newVal.clusterTableList
    }
  },
  methods: {
    validateStrut() {
      let flag
      this.$refs.strutForm.validate(valid => {
        if (valid) {
          flag = '-1'
        } else {
          flag = '1'
        }
      })
      return flag
    }
  }
}
</script>

<style scoped lang="less"></style>
